local lsp_xingying = fk.CreateSkill {
    name = "lsp_xingying",
    anim_type = "drawcard",
    tags = { Skill.Compulsory }
}

Fk:loadTranslationTable {
    ["lsp_xingying"] = "星影",
    [":lsp_xingying"] = "出牌阶段限X次，你可以弃置至少两张牌，若你没有护甲，获得一点护甲。<br>若你弃置的牌均为非伤害牌，你可以视为使用一张伤害类卡牌，若均为伤害牌，你可以视为使用一张非伤害牌(X为体力值，虚拟牌仅可使用单体卡牌)。",
}
lsp_xingying:addEffect("active", {
    prompt = "你可以弃置至少两张牌发动效果",
    min_card_num = 2,
    target_num = 0,
    can_use = function(self, player)
        return player:usedSkillTimes(lsp_xingying.name, Player.HistoryPhase) < player.hp and #player:getCardIds("he") > 0
    end,
    card_filter = function(self, player, to_select, selected)
        return not player:prohibitDiscard(to_select)
    end,
    on_use = function(self, room, effect)
        local player = effect.from
        room:throwCard(effect.cards, lsp_xingying.name, player, player)
        if player.shield == 0 then
            room:changeShield(player, 1)
        end
        local i = 0
        for _, id in ipairs(effect.cards) do
            if Fk:getCardById(id).is_damage_card then
                i = i + 1
            end
        end
        if i == #effect.cards then
            local names = {}
            for _, id in ipairs(Fk:getAllCardIds()) do
                local c = Fk:getCardById(id)
                if not c.is_damage_card and not c.type ~= Card.TypeEquip and not c.multiple_targets and not c.is_derived then
                    table.insertIfNeed(names, Fk:getCardById(id).name)
                end
            end
            if #names > 0 then
                room:askToUseVirtualCard(player, {
                    name = names,
                    skill_name = lsp_xingying.name,
                    cancelable = true,
                    extra_data = {
                        bypass_times = true,
                        extraUse = true,
                        bypass_distances = true,
                    },
                    prompt = "星影：请选择你要是用的非伤害牌",
                })
            end
        end
        if i == 0 then
            local names = {}
            for _, id in ipairs(Fk:getAllCardIds()) do
                local c = Fk:getCardById(id)
                if c.is_damage_card and not c.multiple_targets and not c.is_derived then
                    table.insertIfNeed(names, Fk:getCardById(id).name)
                end
            end
            if #names > 0 then
                room:askToUseVirtualCard(player, {
                    name = names,
                    skill_name = lsp_xingying.name,
                    cancelable = true,
                    extra_data = {
                        bypass_times = true,
                        extraUse = true,
                        bypass_distances = true,
                    },
                    prompt = "星影：请选择你要是用的伤害牌",
                })
            end
        end
    end,
})

return lsp_xingying
